package com.itheima.service.impl;

import com.itheima.entity.CountOption;
import com.itheima.entity.DegreeOption;
import com.itheima.entity.JobOption;
import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private StudentMapper studentMapper;
    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> list = empMapper.countEmpJobData();
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total")).toList();

        return new JobOption(jobList, dataList);
    }

    @Override
    public List<Map> getEmpGenderData() {
        List<Map> list = empMapper.countEmpGenderData();
        return list;
    }

    @Override
    public CountOption getStudentCountData() {
        List<Map<String, Object>> list = studentMapper.countStudentData();
        List<Object> clazzList = list.stream().map(dataMap -> dataMap.get("clazzName")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total")).toList();
        return new CountOption(clazzList, dataList);
    }

    @Override
    public List<Map> getStudentDegreeData() {
        return studentMapper.countStudentDegreeData();
    }

//    @Override
//    public DegreeOption getStudentDegreeData() {
//        List<Map<String, Object>> list = studentMapper.getStudentDegreeData();
//        List<Object> name = list.stream().map(dataMap -> dataMap.get("name")).toList();
//        List<Object> value = list.stream().map(dataMap -> dataMap.get("value")).toList();
//        return new DegreeOption(name, value);
//    }

}
